/*
** accesseur.c for newin-malloc in /home/leroy_v/newin-malloc
**
** Made by vincent leroy
** Login  <leroy_v@epitech.eu>
**
** Started on  Wed Feb 06 16:53:33 2013 vincent leroy
** Last update Wed Feb 06 16:58:41 2013 vincent leroy
*/

#include "malloc.h"

header_t	*cursor;
void		*sbrk0;

header_t*	__getFirstAllocated()
{
    return cursor;
}

void	__setFirstAllocated(header_t* new)
{
    cursor = new;
}

void*	__getSbrk0()
{
    return sbrk0;
}

void	__setSbrk0(void *s)
{
    sbrk0 = s;
}

void*	__searchFree(size_t length)
{
    header_t	*h;

    h = __getFirstAllocated();
    while (h)
    {
        if (h->size == -1 && ((unsigned long)h->next -
            (unsigned long)ADD(h, sizeof(header_t)) > length))
            return h;
        h = h->next;
    }
    return NULL;
}
